package com.xuanyuan.service.impl;

import com.xuanyuan.entity.Users;
import com.xuanyuan.mapper.UsersMapper;
import com.xuanyuan.service.UsersService;
import com.xuanyuan.utils.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//1.实现业务层接口，重写业务层接口方法 alt+enter
//2.注入mapper层接口，调用mapper层方法  ctrl+i
@Service
public class UsersServiceImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;

    @Override
    public ResultVO login(String name, String password) {

        System.out.println(name);
        System.out.println(password);
        Users users = usersMapper.login(name,password);
        System.out.println(users);
        if(users==null){
            //用户名不存在
            return new ResultVO(1000,"用户名不存在",null);
        }else {
            System.out.println(users.getuPwd().equals(password)+"-----");
            //用户名存在
            if(users.getuPwd().equals(password)){
                return new ResultVO(200,"登陆成功",users);
            }else {
            //密码错误
                 return new ResultVO(1002,"密码错误",null);
            }
        }
    }

    @Override
    public List<Users> getUserList() {
        return usersMapper.getUserList();
    }


}
